<?php
namespace Project_725\View\Frontend\Helper;
use TwinPeaks\Core as Core;
use Project_725\Action as Action;
use Project_725\Lib as Lib;
use TwinPeaks\Core\Html as Html;

class Signin extends Core\CTemplate
{
	private $urlManager;
	
	function __construct()
	{
		parent::__construct('@template/signin');
		$this->urlManager = Lib\URLManager::getInstance();
	}
	
	function getCaptcha()
	{
		$capctha = Lib\Captcha::getInstance();
		return $capctha->get();
	}
	
	/**
	 * @return CForm
	 */
	function getForm()
	{
		return new Html\CForm($this->urlManager->getSigninURL());
	}
	
	/**
	 * @return boolean
	 */
	function getWrongCredentials()
	{
		return $this->action->hasError(Action\Signin::ERR_WRONG_CREDENTIALS);
	}
	
	/**
	 * @return boolean
	 */
	function getWrongCaptcha()
	{
		return $this->action->hasError(Action\Signin::ERR_WRONG_CAPTCHA);
	}
}
